< previous page page_899 next page >

Page 899
    If blnSQLQuiet = False Then
        MsgBox cMsg, vbCritical, cModule
    End If
    '
End Sub
No real magic in this routine. Listing A.25 is passed the Visual Basic error number and error message, the script line number and script line text, and the name of the SQL-VB5 routine that experienced the error. All this is formatted into a readable (if not entirely welcome) message that is displayed to the user. Notice that you used the tabs (Chr(9)) and carriage returns (Chr(13)) to make the information easier to read.
The routine in Listing A.26 handles all the initialization chores for the start of a script. It is also called whenever an error is reported and when the program is exited. Create a Public Sub procedure called InitApp and enter the code in Listing A.26.
Type.gifListing A.26. Coding the InitApp routine.
Sub InitApp()
    '
    ' set up app values
    '
    On Error Resume Next ' ignore any errors here
    '
    ' close all child forms
    For x = 0 To intForms
       Unload TblForms(x)
       Set TblForms(x) = Nothing
    Next x
    '
    ' close open database
    If intDBFlag = True Then
       db.Close
       Set db = Nothing
       Set ws = Nothing
    End If
    '
    ' close open script file
    If intSQLFlag = True Then
       Close (intSQLFileHandle)
    End If
    '
    ' reset flags & stuff
    nSQLFile = ""
    intSQLFlag = False
    intDBFlag = False
    nGlobalErr = False
    blnSQLQuiet = False
    intLine = 0
    strConnect = "" ' "Access;"
continues

 
< previous page page_899 next page >

If you like this book, buy it!